
import serve from './financeApi'

export default{
  /* 财务看板接口token */
  login (params) {
    return serve.post('/api/v1/token', params)
  },
  /* 财务看板 */
  /* 实际收入与计划收入 */
  income (params) {
    let props = getparams(params)
    console.log(props)
    return serve.get('/api/v1/chart/income?' + props)
  },
  /* 查询收益与盈亏 （总盈亏，3日盈亏对比） */
  profitAndCost (params) {
    let props = getparams(params)
    return serve.get('/api/v1/chart/profitAndCost?' + props)
  },
  /* 年度总盈亏 */
  profit (params) {
    let props = getparams(params)
    return serve.get('/api/v1/report/finance?'+ props)
  },
  /* 实际投入 */
  cost (params) {
    let props = getparams(params)
    return serve.get('/api/v1/chart/cost?' + props)
  },

  //签到排名
  signIn(params) {
    return serve.get('http://192.168.11.154:9101/attendancetop', params)
  },
  
}

let getparams = (params) => {
  let str = ''
  let key = Object.keys(params)
  key.forEach((item, index) => {
    if (!index) {
      str += item + '=' + params[item]
    } else {
      str += '&' + item + '=' + params[item]
    }
  })
  return str
}